package com.itheima;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo {
    public static void main(String[] args) {
        //1.创建集合对象
        Map<String,Double> map = new HashMap<>();
        //2.添加元素
        map.put("张三",18.0);
        map.put("李四",19.0);
        map.put("王五",20.0);
        map.put("赵六",21.0);
        map.put("赵六",22.0);
        Set<String> keySet = map.keySet();
        for(String key:keySet){
            Double  value = map.get(key);
            System.out.println(key+"--"+value);
        }}
        //3.获取元素
    private static void test0(){
        Map<String,Double> map = new HashMap<>();
        map.put("张三",18.0);
        map.put("李四",19.0);
        map.put("王五",20.0);
        map.put("赵六",21.0);
        map.put("赵六",22.0);
        System.out.println(map);

        map.remove("张三");
        System.out.println(map);
        map.clear();
        System.out.println(map);
        boolean b=map.containsKey("张三");
        System.out.println(b);
        boolean b1=map.containsValue(18.0);
        System.out.println(b1);
    }
}
